<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <!-- 1.开发环境版本 -->
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
  </head>
  <body>
    <!--v-on：
            为元素绑定事件
            事件名不需要写on
            指令可以简写为@
            方法定义在methods属性中 
     -->
    <!-- 2.html结构 -->
    <div id="app">
      <input type="button" value="v-on指令" v-on:click="doIt" />
      <input type="button" value="@简写" @click="doIt" />
      <input type="button" value="双击事件" @dblclick="doIt" />
      <h2 @click="changeFood">{{food}}</h2>
    </div>
    <!-- 3.创建vue实例 -->
    <script>
      var app = new Vue({
        el: "#app",
        data: {
          food: "老八秘制小汉堡",
        },
        methods: {
          doIt: function () {
            alert("嗨嗨嗨");
          },
          changeFood: function () {
            /* console.log(this.food); */
            this.food += "好好吃！";
          },
        },
      });
    </script>
  </body>
</html>
